package cn.ivicar.iov.controller;

import cn.ivicar.iov.entity.FlowPackageHistory;
import cn.ivicar.iov.entity.Result;
import cn.ivicar.iov.service.FlowPackageHistoryService;
import cn.ivicar.iov.service.SimInfoService;
import cn.ivicar.iov.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: iov
 * @description: ${description}
 * @author: Mr.huang
 * @create: 2018-08-20 16:52
 **/
@RestController
public class FlowPackageHistoryController {
    @Autowired
    private FlowPackageHistoryService flowPackageHistoryService;
    @Autowired
    private SimInfoService simInfoService;

    @GetMapping(value = "/packagehistory")
    @ResponseBody
    public Boolean addFlowPackageHistory(@RequestParam("vehicle_serial") String vehicle_serial, @RequestParam("flow_package_id") Integer flow_package_id){
        boolean IsInsert = flowPackageHistoryService.addHistoryPackage(vehicle_serial,flow_package_id);
        return  IsInsert;
    }

    /**
     * 获得历史订单信息
     * @param vehicle_serial
     * @return
     * @ResponseBody
     */
    @GetMapping(value = "getHistoryPackage")
    public Result listFlowPackageHistory(@RequestParam("vehicle_serial") String vehicle_serial){
        return ResultUtil.success(flowPackageHistoryService.getHistoryPackage(vehicle_serial));
    }

    /*
    显示卡信息
    @ResponseBody
     */
        @GetMapping(value = "/siminfo")
        public Result getSimInfo(@RequestParam("vehicleSerial") String vehicleSerial){
            return ResultUtil.success(simInfoService.getSimInfo(vehicleSerial));
        }
    /*
    导出注销卡信息
     */
        @GetMapping(value = "/outputData")
        public Result outputData(HttpServletResponse response){
            simInfoService.outputData(response);
            return ResultUtil.success();
    }
}